package org.example;

public class Test2 {
    //leetcode 45 跳跃游戏II https://leetcode.cn/problems/jump-game-ii/description/
    public int jump(int[] nums) {
        int step = 0,max = 0,end = 0,n = nums.length;
        for (int i = 0; i < n - 1; i++) {
            max = Math.max(max,i + nums[i]);
            if (i == end) {
                step++;
                end = max;
            }
        }
        return step;
    }
}
